import request from '@/config/axios'

import { BaseModel } from '@/api/common/baseModel'

export interface Model extends BaseModel {
  parentId: string
  leaderUserId: string
  phone: string
  email: string
  createTime: Date
}

// 查询部门（精简)列表
export const getList = async (): Promise<Model[]> => {
  return await request.get({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/dept/dept/arr.json' })
}

// 查询部门列表
export const getPage = async (params: PageParam) => {
  return await request.get({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/dept/dept/arr.json', params })
}

// 查询部门详情
export const getById = async (id: string) => {
  return await request.get({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/dept/dept/getById.json?id=' + id })
}

// 修改部门
export const update = async (params: Model) => {
  return await request.put({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/dept/dept/update.json', data: params })
}

// 删除部门
export const del = async (id: string) => {
  return await request.delete({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/dept/dept/del.json?id=' + id })
}
